package chd.edu.spzx.user.service.impl;

import chd.edu.spzx.model.entity.user.UserAddress;
import chd.edu.spzx.user.mapper.UserAddressMapper;
import chd.edu.spzx.user.service.UserAddressService;
import chd.edu.spzx.utils.AuthContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zhang Chaoliang
 * create 2023
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Autowired
    private UserAddressMapper userAddressMapper;

    /**
     * 获取用户地址列表
     * @return
     */
    @Override
    public List<UserAddress> findUserAddressList() {
        Long userId = AuthContextUtil.getUserInfo().getId();
        return userAddressMapper.findUserAddressList(userId);
    }

    /**
     * 根据id获取收货地址
     * @param id
     * @return
     */
    @Override
    public UserAddress getUserAddress(Long id) {
        return userAddressMapper.getUserAddress(id);
    }
}
